<?php

namespace App\Http\Controllers\Api\v1;

use App\Http\Controllers\Controller;
use App\Logic\BorkerLogic;
use Illuminate\Http\Request;
use App\common;
use App\server\RedisServer;
use Illuminate\Support\Facades\Redis;

/**
 * Undocumented class
 *  @zf
 * 经纪人
 */
class BorkerController extends Controller
{
    //经纪人信息
    public function index(Request $request){
        try{
            if($request->method()!= 'GET')throw new \Exception('请求方式不正确');
            $name=$request->get('name');
            $phone=$request->get('phone');
            $paginate=$request->get('paginate');
            $borkerList=BorkerLogic::BorkerList($name,$phone,$paginate);
            return common::success(20000,$borkerList,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
     /**
     * Undocumented function
     *  经纪人详情
     * @return void
     */
    public function brokerDetail(Request $request){
        try{
            if($request->method()!= 'GET')throw new \Exception('请求方式不正确');
            $id=$request->get('id');
            $adminDetail=BorkerLogic::BorkerDetail($id);
            return common::success(20000,$adminDetail,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
    /**
     * Undocumented function
     *  删除经纪人信息
     * @return void
     */
    public function brokerDel(Request $request){
        try{
            if($request->method()!= 'GET')throw new \Exception('请求方式不正确');
            $id=$request->get('id');
            $adminDetail=BorkerLogic::BorkerDel($id);
            return common::success(20000,$adminDetail,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
    /**
     * Undocumented function
     *  编辑经纪人信息
     * @return void
     */
    public function brokerSave(Request $request){
        try{
            if($request->method()!= 'POST')throw new \Exception('请求方式不正确');
            $updata=$request->post();

            $BorkerSave=BorkerLogic::BorkerSave($updata,$request);
            return common::success(20000,$BorkerSave,'加载成功');

        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
     }
      /**
     * Undocumented function
     *  经纪人信息redis
     * @return void
     */
    public function borkerRedis(Request $request){
        try{
            $status=BorkerLogic::BorkeRedis();
            return common::success(20000,$status,'存入成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
}
